@extends('layouts.app')
@section('title', '员工信息')

@section('content')
    <div class="tab">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12">
                    <table class="table table-striped">
                        <caption>员工基本信息</caption>
                        <thead>
                            <tr>
                                <th>员工编号</th>
                                <th>姓名</th>
                                <th>联系方式</th>
                                <th>职务</th>
                                <th>员工生日</th>
                                <th>所属部门</th>
                                @if(Auth::user()->id == 1)
                                    <th>操作说明</th>
                                @endif
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($employee as $v)
                            <tr id="{{$v->id}}">
                                <td>{{$v->id}}</td>
                                <td>{{$v->name}}</td>
                                <td>{{$v->tel}}</td>
                                <td>{{$v->post}}</td>
                                <td>{{$v->birth}}</td>
                                <td>{{$v->department}}</td>
                                @if(Auth::user()->id == 1)
                                    <td>
                                        <a class="update btn btn-info" onclick="upd('{{ $v->id }}')" style="float: left">修改</a>

                                        <form action="{{ route('employees.destroy', [$v->id]) }}" method="post" style="float: left" >
                                            {{ csrf_field() }}
                                            {{ method_field('DELETE') }}
                                            <button type="submit" class="btn btn-danger">删除</button>
                                        </form>
                                    </td>
                                @endif
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                    @if(Auth::user()->id == 1)
                        <a class="pull-right"{{-- href="{{ route('employee.add_employee') }}"--}} id="add_form">添加员工</a>
                    @endif
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="text-center">
                        {{$employee->render()}}
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
<div id="zzz" style="display: none">
    <form class="form-horizontal"  id="addForm" role="form" action="{{ url('/employee/add_employee') }}" method="post">
        <div class="form-group">
            <label  class="col-sm-4 control-label">姓名</label>
            <div class="col-sm-6">
                <input type="text" class="form-control"  name="name" id="username" placeholder="请输入名字">
            </div>
        </div>
        <div class="form-group">
            <label for="lastname" class="col-sm-4 control-label">联系方式</label>
            <div class="col-sm-6">
                <input type="text" class="form-control"  name="tel" id="usertel" placeholder="请输入联系方式">
            </div>
        </div>
        <div class="form-group">
            <label for="lastname" class="col-sm-4 control-label">员工生日</label>
            <div class="col-sm-6">
                <input type="date" class="form-control" name="birth" placeholder="请输入员工生日">
            </div>
        </div>
        <div class="form-group">
            <label for="lastname" class="col-sm-4 control-label">职务</label>
            <div class="col-sm-6">
                <input type="text" class="form-control"  name="post" placeholder="请输入职务">
            </div>
        </div>
        <div class="form-group">
            <label for="lastname" class="col-sm-4 control-label">所属部门</label>
            <div class="col-sm-6">
                <input type="text" class="form-control"  name="department" placeholder="请输入所属部门">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-4 col-sm-8">
                <button type="submit" class="btn btn-default">add</button>
            </div>
        </div>
        {{ csrf_field() }}
    </form>
</div>

<link rel="stylesheet" type="text/css" href="css/employee.css"/>

@section('script')
    <script src="js/employee.js"></script>
@endsection